package br.mil.eb.pqrmnt7.scc.entity;



import org.apache.myfaces.extensions.validator.crossval.annotation.RequiredIf;
import javax.validation.constraints.NotNull;
import org.apache.myfaces.extensions.validator.crossval.annotation.RequiredIfType;
import javax.persistence.Id;
import javax.validation.constraints.Size;
import javax.persistence.GenerationType;
import javax.persistence.MappedSuperclass;
import com.powerlogic.jcompany.config.domain.PlcReference;
import com.powerlogic.jcompany.domain.validation.PlcValGroupEntityList;
import javax.persistence.GeneratedValue;
@MappedSuperclass
public abstract class TipoCombustivel extends AppBaseEntity {

	public static final TipoCombustivel GASOLINA = new TipoCombustivelEntity("Gasolina");
	public static final TipoCombustivel DIESEL = new TipoCombustivelEntity("Díesel");	
	
	@Id 
 	@GeneratedValue(strategy=GenerationType.AUTO, generator = "SE_TIPO_COMBUSTIVEL")
	private Long id;

	@NotNull(groups=PlcValGroupEntityList.class)
	@RequiredIf(valueOf="id",is=RequiredIfType.not_empty)
	@Size(max = 20)
	@PlcReference(testDuplicity=true)
	private String nome;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id=id;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome=nome;
	}

	public boolean isGasolina() {
		return this.getNome().equalsIgnoreCase(GASOLINA.getNome());
	}

	public boolean isDiesel() {
		return this.getNome().equalsIgnoreCase(DIESEL.getNome());
	}
	
}
